package drds.binlog.parse.driver.packets.client;

import drds.binlog.common.Authors;
import drds.binlog.parse.driver.packets.CommandPacket;
import drds.common.Author;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

@Author(name = Authors.LI_YANG)
public class QueryCommandPacket extends CommandPacket
{

    private String queryString;

    public QueryCommandPacket()
    {
        setCommand((byte) 0x03);
    }

    public void fromBytes(byte[] bytes) throws IOException
    {
    }

    public byte[] toBytes() throws IOException
    {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byteArrayOutputStream.write(getCommand());
        byteArrayOutputStream.write(getQueryString().getBytes("UTF-8"));// 链接建立时默认指定编码为UTF-8
        return byteArrayOutputStream.toByteArray();
    }

    public String getQueryString()
    {
        return queryString;
    }

    public void setQueryString(String queryString)
    {
        this.queryString = queryString;
    }

}
